using System;
using System.Collections.Generic;

namespace JlPay.Sdk.Models.Ledger.BalanceSplit
{
    /// <summary>
    /// 接收方信息
    /// </summary>
    public class Receiver
    {
        /// <summary>
        /// 接收方商户号
        /// </summary>
        public string RevMchId { get; set; } = string.Empty;

        /// <summary>
        /// 金额
        /// </summary>
        public string Amount { get; set; } = string.Empty;

        /// <summary>
        /// 描述
        /// </summary>
        public string Description { get; set; } = string.Empty;

        /// <summary>
        /// 结果
        /// </summary>
        public string Result { get; set; } = string.Empty;

        /// <summary>
        /// 失败原因
        /// </summary>
        public string FailReason { get; set; } = string.Empty;

        /// <summary>
        /// 明细ID
        /// </summary>
        public string DetailId { get; set; } = string.Empty;

        /// <summary>
        /// 创建时间
        /// </summary>
        public string CreateTime { get; set; } = string.Empty;

        /// <summary>
        /// 完成时间
        /// </summary>
        public string FinishTime { get; set; } = string.Empty;

        /// <summary>
        /// 构造函数
        /// </summary>
        public Receiver()
        {
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="receiverData">接收方数据字典</param>
        public Receiver(Dictionary<string, object> receiverData)
        {
            if (receiverData != null)
            {
                RevMchId = receiverData.GetValueOrDefault("rev_mch_id", "").ToString() ?? string.Empty;
                Amount = receiverData.GetValueOrDefault("amount", "").ToString() ?? string.Empty;
                Description = receiverData.GetValueOrDefault("description", "").ToString() ?? string.Empty;
                Result = receiverData.GetValueOrDefault("result", "").ToString() ?? string.Empty;
                FailReason = receiverData.GetValueOrDefault("fail_reason", "").ToString() ?? string.Empty;
                DetailId = receiverData.GetValueOrDefault("detail_id", "").ToString() ?? string.Empty;
                CreateTime = receiverData.GetValueOrDefault("create_time", "").ToString() ?? string.Empty;
                FinishTime = receiverData.GetValueOrDefault("finish_time", "").ToString() ?? string.Empty;
            }
        }

        /// <summary>
        /// 转换为字典
        /// </summary>
        /// <returns>字典对象</returns>
        public Dictionary<string, object> ToDictionary()
        {
            return new Dictionary<string, object>
            {
                ["rev_mch_id"] = RevMchId,
                ["amount"] = Amount,
                ["description"] = Description,
                ["result"] = Result,
                ["fail_reason"] = FailReason,
                ["detail_id"] = DetailId,
                ["create_time"] = CreateTime,
                ["finish_time"] = FinishTime
            };
        }
    }
} 